package a;

/**
 * 项目8 泛型与集合框架
 */
//p182 泛型类的应用
public class demo1<T> {
    private T obj;
    public T getObj(){
        return obj;
    }
    public void setObj(T obj){
        this.obj = obj;
    }
    public static void main(String[] args) {
        demo1<String> name = new demo1<String>();
        demo1<Double> price = new demo1<Double>();
        name.setObj("杯子");
        String shopName = name.getObj();
        System.out.println("商品名称："+ shopName);
        price.setObj(8.6);
        double shopPrice = price.getObj();
        System.out.println("商品价格：" + shopPrice + "元");
    }
}
